<template>
  <div>
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="班级名称">
        <el-input v-model="form.className"></el-input>
      </el-form-item>
      <el-form-item label="班级类型">
        <el-input v-model="form.classType"></el-input>
      </el-form-item>
      <el-form-item label="班级人数">
        <el-input v-model="form.classNumber"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">确认</el-button>
        <el-button type="info" @click="cancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "ClassUpdate",
  data() {
    return {
      form: {
        className: "",
        classType: "",
        classNumber: "",
      },
    };
  },
  methods: {
    async onSubmit() {
      //console.log(this.form);
      let result = await this.$http.updateClass(
        this.form.className,
        this.form.classType,
        this.form.classNumber,
        this.$route.query.id
      );
      if(result.code==20000)
      {
        console.log(result);
        alert("更新成功！");
        this.$router.push('/Adminpage/Class');
      }
      else{
        alert("更新失败！");
        this.$router.push('/Adminpage/Class');
      }

    },
    cancel(){
        this.$router.push('/Adminpage/Class');
    }
  },
};
</script>
<style scoped>

</style>
